<%@page import="util.Utilities"%>
<%@page import="dao.Teacher"%>
<%@page import="beans.Teacherbean"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
	String grade = (String)session.getAttribute("grade");
	Teacherbean teacherbean = new Teacherbean();
	List<Teacher> teachers = teacherbean.getTeachersByGrade(grade);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>教师信息</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<style type="text/css">
body {
	font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica,
		sans-serif;
	color: #4f6b72;
	text-align: center;
	background: #E6EAE9;
}

#container {
	margin-left: auto;
	margin-right: auto;
	width: 1000px;
	height: 100%;
	background: #f8f8f8;
	border: 2px solid #777;
	display: block;
	vertical-align: middle;
}

.ele {
	margin-top: 20px;
	margin-botton: 10px;
	text-align: center;
	width: 100%;
	display: block;
	vertical-align: middle;
}
</style>
<script type="text/javascript">
function sendMessage (url) {
	window.open (url, "留言", "height=450, width=700, top=150, left=250, toolbar= no, menubar=no, scrollbars=no, resizable=no, location=no, status=no"); 
}
</script>
  </head>
  
  <body>
    <div id="container">
	<c:choose>
		<c:when test="<%=teachers ==null %>">
			<c:out value="参数有误，没有相应年级的教师信息"></c:out>
		</c:when>
		<c:otherwise>
			<%
			    for (Teacher teacher: teachers) {
				String sex = teacher.getSex().equals("0")?"男":"女";
				String courseName = Utilities.getCourseName(teacher.getCourseid().substring(2));
			%>
			<div class="ele">
			<label>姓名：</label><%=teacher.getName() %><br>
			<label>性别：</label><%=sex %><br>
			<label>所教科目：</label><%=courseName %><br>
			<label>介绍：</label><%=teacher.getDescription() %><br>
			<a href="javascript:sendMessage('./common/sendMessage.jsp?destination=<%=teacher.getTeacherid() %>');" >留言</a>
			</div>
			<hr>
			<%
			    }
			%>
		</c:otherwise>
	</c:choose>
	</div>
  </body>
</html>
